import 'package:flutter/material.dart';
import 'package:flutter_sample/pages/plugin_page.dart';
import 'package:go_router/go_router.dart';

void main() {
  runApp(const MyFlavorApp());
}

class MyFlavorApp extends StatelessWidget {
  const MyFlavorApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routerConfig: GoRouter(
        routes: [
          GoRoute(
            path: '/',
            builder: (_, __) => const MyFlavorPage(),
            routes: [
              GoRoute(
                path: 'second',
                builder: (context, state) => const PluginPage(),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

class MyFlavorPage extends StatefulWidget {
  const MyFlavorPage({super.key});

  @override
  State<MyFlavorPage> createState() => _MyFlavorPageState();
}

class _MyFlavorPageState extends State<MyFlavorPage> {
  @override
  Widget build(BuildContext context) {

    var flag = MediaQuery.of(context).alwaysUse24HourFormat;
    print(flag);
    return Scaffold(
      appBar: AppBar(title: const Text('myFlavor')),
      body: _buildWidgetNoScroll(context),
    );
  }

  _buildWidgetNoScroll(BuildContext context) {
    return Column(
      children: [
        const SizedBox(height: 100),
        const TextField(
          decoration: InputDecoration(border: OutlineInputBorder()),
        ),
        ElevatedButton(onPressed: () {}, child: const Text('test1')),
        ElevatedButton(onPressed: () {}, child: const Text('test2')),
        ElevatedButton(onPressed: () {}, child: const Text('test3')),
        ElevatedButton(onPressed: () {}, child: const Text('test4')),
      ],
    );
  }

  _buildWidget(BuildContext context) {
    return Flex(
      direction: Axis.vertical,
      children: [
        Expanded(
          flex: 1,
          child: Container(
            color: Colors.blueAccent,
            child: const TextField(
              decoration: InputDecoration(
                border: OutlineInputBorder(),
                hintText: 'Enter a search term',
              ),
            ),
          ),
        ),
        Expanded(
          flex: 1,
          child: Container(color: Colors.redAccent),
        ),
        const Text('data'),
      ],
    );
  }
}
